﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using QLST_DTO;

namespace QLST_DAO
{
    public class LOAINHANVIENDAO : TempDAO
    {
        /// <summary>
        /// Lay Thong Tin Loai Nhan Vien
        /// </summary>
        /// <param name="MaLoai"></param>
        /// <returns></returns>
        public LOAI_NHAN_VIEN GET(int MaLoai)
        {
            SqlParameter[] para = new SqlParameter[]{new SqlParameter("@MaLoai",MaLoai)};
            DataTable tbl = dap.ExcuteProcedureGetTable("st_SelectLoaiNhanVien", para);
            DataRow dr = tbl.Rows[0];
            LOAI_NHAN_VIEN lnv = new LOAI_NHAN_VIEN();
            lnv.MaLoai = int.Parse(dr["MaLoai"].ToString());
            lnv.TenLoai = dr["TenLoai"].ToString();
            lnv.MoTa = dr["MoTa"].ToString();
            return lnv;
        }

        public List<LOAI_NHAN_VIEN> GetDs()
        {
            List<LOAI_NHAN_VIEN> lst = new List<LOAI_NHAN_VIEN>();
            DataTable tbl = dap.ExcuteProcedureGetTable("st_SelectDsLoaiNhanVien", null);
            foreach (DataRow dr in tbl.Rows)
            {
                LOAI_NHAN_VIEN lnv = new LOAI_NHAN_VIEN();
                lnv.MaLoai = int.Parse(dr["MaLoai"].ToString());
                lnv.TenLoai = dr["TenLoai"].ToString();
                lnv.MoTa = dr["MoTa"].ToString();
                lst.Add(lnv);
            }
            return lst;
        }

        public int Insert(LOAI_NHAN_VIEN lnv)
        {
            SqlParameter[] para = new SqlParameter[] { new SqlParameter("@TenLoai",lnv.TenLoai),new SqlParameter("@MoTa",lnv.MoTa) };
            return dap.ExcuteProcedureWithReturn("st_InsertLoaiNhanVien", para);
        }

    }
}
